<template>
  <div class="wh-100">
    <!--头部-->
    <div class="w-100 h-10 d-flex d-flex-center py-20">
      <el-select no-match-text="暂无数据"  no-data-text="暂无数据" class="w-10" size="small" v-model="school"  placeholder="请选择学校">
        <el-option label="全部学校" value="全部学校"></el-option>
        <el-option
            v-for="item in schoolList"
            :key="item.id"
            :label="item.name"
            :value="item.name">
        </el-option>
      </el-select>
        <el-select no-match-text="暂无数据"  no-data-text="暂无数据" class="w-10" size="small" v-model="pageParams.education"  placeholder="请选择学历">
            <el-option label="全部学历" value="全部学历"></el-option>
            <el-option v-for="item in educationBackgroundOptions" :key="item" :label="item" :value="item"></el-option>
        </el-select>
        <el-select no-match-text="暂无数据"  no-data-text="暂无数据" class="w-10" size="small" v-model="placeOfStudentOrigin"  placeholder="请选择生源所在地">
            <el-option label="生源所在地" value="生源所在地"></el-option>
            <el-option v-for="item in placeOfStudentOriginOptions" :key="item.value" :label="item.name" :value="item.provincePy"></el-option>
        </el-select>
      <div class="w-30 ml-24 d-flex">
        <el-input class="" placeholder="按专业名称查找，多个专业中文逗号分开" v-model="pageParams.search" ></el-input>
        <el-button style="background-color: #1890ff;color: white" @click="toSearch">搜索</el-button>
      </div>

    </div>
    <!--表格-->
    <div class="h-80">
      <Table :columns="tablecolumns" :data="tableData" :loading="loading"  class="overflow-auto-hidden" style="max-height: 100%" ellipsis></Table>
    </div>
    <!--分页-->
    <div class="h-10 d-flex-center">
      <Page  show-sizer
             :total="pageTotal"
             :current="pageParams.pageNumber"
             :page-size="pageParams.pageSize"
             @on-change="changePage"
             no-filtered-data-text="暂无数据"
             @on-page-size-change="changePageSize"
             show-elevator />
    </div>
  </div>
</template>
<script>
import {
    getTheSchoolNameAPI, obtainADiplomaAPI,
    obtainTheLocationOfStudentsAPI,
    searchByCollegeAndProfessionAPI
} from '../../../api/bys/recruitmentManagement';

export default {
  data() {
    return {
      loading:false,
      pageTotal:0,
      pageParams:{
        education:'全部学历',
        syszd:'生源所在地',
        college:'全部学校',//学校名称
        search:'',//专业名称
        tableId:'',//表id
        pageSize:10,//
        pageNumber:1
      },
      schoolList:[],
      tablecolumns:[
        {title:'学校',key:'college',width:'100',align:'left',tooltip:'true'},
        {title:'专业',key:'profession',width:'120',align:'left',tooltip:'true'},
        {title: '分学历层次毕业生人数',align:'center',tooltip:'true',
          children:[
            {title:'博士研究生',key:'doctoralCandidate',align:'center',tooltip:'true'},
            {title:'硕士研究生',key:'masterCandidate',align:'center',tooltip:'true'},
            {title:'本科',key:'bachelorDegree',align:'center',tooltip:'true'},
            {title:'专科',key:'juniorCollege',align:'center',tooltip:'true'},
          ]
        },
        {title:'分地区毕业生人数',align:'center',tooltip:'true',
          children:[
            {title:'郑州',key:'zz',align:'center',tooltip:'true'},
            {title:'开封',key:'kf',align:'center',tooltip:'true'},
            {title:'洛阳',key:'ly',align:'center',tooltip:'true'},
            {title:'平顶山',key:'pds',align:'center',tooltip:'true'},
            {title:'安阳',key:'ay',align:'center',tooltip:'true'},
            {title:'鹤壁',key:'hb',align:'center',tooltip:'true'},
            {title:'新乡',key:'xx',align:'center',tooltip:'true'},
            {title:'焦作',key:'jz',align:'center',tooltip:'true'},
            {title:'濮阳',key:'py',align:'center',tooltip:'true'},
            {title:'许昌',key:'xc',align:'center',tooltip:'true'},
            {title:'漯河',key:'lh',align:'center',tooltip:'true'},
            {title:'三门峡',key:'smx',align:'center',tooltip:'true'},
            {title:'南阳',key:'ny',align:'center',tooltip:'true'},
            {title:'商丘',key:'sq',align:'center',tooltip:'true'},
            {title:'信阳',key:'xy',align:'center',tooltip:'true'},
            {title:'周口',key:'zk',align:'center',tooltip:'true'},
            {title:'驻马店',key:'zmd',align:'center',tooltip:'true'},
            {title:'济源',key:'jy',align:'center',tooltip:'true'},
            {title:'省外',key:'sw',align:'center',tooltip:'true'},
          ]
        },
        {title:'合计',key:'hj',align:'center',tooltip:'true'}
      ],
      tableData:[],
      schoolSelect:[{}],
        school: '全部学校',
        placeOfStudentOrigin: '生源所在地',
      educationBackgroundOptions: null,
      placeOfStudentOriginOptions: null
    }

  },
  mounted() {
    this.pageParams.tableId = this.$route.query.id
    this.getList()
    this.getDictData()
  },
  methods:{
    getList() {
        if (this.school == '全部学校') {
            this.pageParams.college = null;
        }else {
            this.pageParams.college = this.school;
        }

        if (this.placeOfStudentOrigin == '生源所在地') {
            this.pageParams.syszd = null;
        }else{
            this.pageParams.syszd = this.placeOfStudentOrigin;
        }
      //调接口
      this.loading = true
      searchByCollegeAndProfessionAPI(this.pageParams).then((res) => {
        if (res.success) {
          this.tableData = res?.result?.result || []
          this.pageTotal = res?.result?.total || 0
          this.loading = false
        }else{
          this.loading = false
        }

      }).catch((err) => {
        console.log(err)
        this.loading = false
      })
    },
    toSearch() {
      this.getList()
    },
    getDictData() {
      //获取学校数据
      getTheSchoolNameAPI().then((res) => {
        console.log(res.result)
        this.schoolList = res.result
      })
        /*获取生源所在地数据*/
        obtainTheLocationOfStudentsAPI().then(res => {
            this.placeOfStudentOriginOptions = res.result;
        });
        // 获取学历数据
        obtainADiplomaAPI().then(res => {
            this.educationBackgroundOptions = res.result;
            console.log('this.educationBackgroundOptions', res);
        });
    },
    changePage:function (val){
      this.pageParams.pageNumber=val;
      this.getList();
    },
    changePageSize:function (val){
      this.pageParams.pageSize=val;
      this.getList();
    }
  }
}
</script>
